import requests
from lxml import etree

url = 'https://github.com/trending'
datas = []
response = requests.get(url)
tree = etree.HTML(response.text)
titles = tree.xpath('//h2[@class="h3 lh-condensed"][1]/a[@class="Link"][1]')
for title in titles:
    last = title.xpath('./text()')[1].strip()
    head = title.xpath('./span/text()')[0].strip()
    head = head.split(' ')
    head = ''.join(head)
    detail_url = 'https://github.com/' + head + last
    info = title.xpath('../../p[@class="col-9 color-fg-muted my-1 pr-4"]/text()')[0].strip()
    datas.append({
        'title': head + last,
        'link': detail_url,
        'info': info,
    })

print(datas)
